package commonFunction;

import java.io.IOException;

import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;

public class TestngListener implements ITestListener {
		

		
	   public void onTestFailure(ITestResult result) {  
	        try {  
	        	ScreenShotOnFailure s=(ScreenShotOnFailure)result.getInstance();
	        	
	            s.takeScreentShot();
	            System.out.println(result.getMethod().getMethodName() + " failed, the screenshot saved in："  
	                    + ScreenShotOnFailure.getScreenShotPath() + "； screenshot name : "  
	                    + ScreenShotOnFailure.getScreenShotName());  
	        } catch (IOException e) {  
	            e.printStackTrace();  
	        }  
	    }  
	  
	    public void onTestStart(ITestResult result) {  
	        // TODO Auto-generated method stub  
	  
	    }  
	  
	    public void onTestSuccess(ITestResult result) {  
	        // TODO Auto-generated method stub  
	    }  
	  
	    public void onTestSkipped(ITestResult result) {  
	        // TODO Auto-generated method stub  
	  
	    }  
	  
	    public void onTestFailedButWithinSuccessPercentage(ITestResult result) {  
	        // TODO Auto-generated method stub  
	  
	    }  
	  
	    public void onStart(ITestContext context) {  
	        // TODO Auto-generated method stub  
	  
	    }

		@Override
		public void onFinish(ITestContext arg0) {
			// TODO Auto-generated method stub
			
		}  
}
